#!/usr/bin/perl

require "./mailadmin-lib.pl";
&ReadParse();

my ($dname, @ulist, $password, $uquota, $err_msg);

$dname = $in{'dname'};
@ulist = split(':', $in{'unamecache'});
$password = $in{'passwd'};
$uquota = $in{'uquota'};


#&header($text{'index_title'}, "", "index", 0, 1);

unless ($dname)
{
    $err_msg = $text{'msg_dname_empty'};
    goto ERROR_OUT;
}

unless ($in{'unamecache'})
{
    $err_msg = $text{'msg_uname_empty'};
    goto ERROR_OUT;
}

$err_msg = &check_input_num($uquota);
if ($err_msg)
{
    goto ERROR_OUT;
}

if ($uquota < 1)
{
    $uquota = 1;
}

$err_msg = &create_user(\@ulist, $dname, $password, $uquota);

if ($err_msg)
{
    goto ERROR_OUT;
}

&redirect("list_user.cgi?dname=$in{'dname'}");

#&footer("list_user.cgi?dname=$in{'dname'}", $text{"back_lsuser"});
exit 0;

 ERROR_OUT:;
my (@headp, @footp);
@headp = ($text{'error'}, "");
@footp = ("list_user.cgi?dname=$in{'dname'}", $text{'back_lsuser'});
&mail_error(\@headp, \@footp, $text{'err_title_save_create_user'}, $err_msg);

